package com.pe.pgn.clubpgn.webapp.controller.anulacionreserva;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import com.pe.pgn.clubpgn.domain.beans.BNDocumentoMovArticulo;
import com.pe.pgn.clubpgn.service.AnulacionReservaService;
import com.pe.pgn.clubpgn.webapp.controller.BaseFormController;

@Controller
@RequestMapping("/anulacionreserva/**")
public class AnulacionReservaController extends BaseFormController {

	@Autowired AnulacionReservaService anureservaService;
	
	@RequestMapping(value = "/anulacionreserva.html", method = RequestMethod.GET)
	public String verCanjePremio(
		   @RequestParam(value = "id", required = true) Long id ,
		   @RequestParam(value = "coCodigoPremio", required = true) String coCodigoPremio ,
		   Model model) {

		BNDocumentoMovArticulo bnCanje  = new BNDocumentoMovArticulo();
		
		if (id != null) { 			
			bnCanje  = anureservaService.obtenerDocumentoReserva(id);
			bnCanje.setCoCodigoPremio(coCodigoPremio);
			anureservaService.guardarAnulacionReserv(bnCanje);			
		}
		
		model.addAttribute("canjeform" , bnCanje);
		return "redirect:../canje/canjeform.html?from=list&id="+bnCanje.getId();
	}		
}
